package com.gjk.ordering.system.commons.utils;

public class RegexpUtils {


    /**
     * 验证邮箱地址
     */
    public static final String EMAIL = "\\w+(\\.\\w)*@\\w+(\\.\\w{2,3}){1,3}";

    /**
     * 验证密码
     */
    public static final String PASSWORD = "^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]{6,20})$";

    /**
     * 验证姓名中文
     */
    public static final String USERNAME = "^[\\u4E00-\\u9FA5\\uf900-\\ufa2d·s]{2,20}$";


    /**
     * 验证邮箱
     * @param email
     * @return
     */
    public static boolean checkEmail(String email) {
        return email.matches(EMAIL);
    }

    /**
     * 验证密码
     * @param password
     * @return
     */
    public static boolean checkPassword(String password){
        return password.matches(PASSWORD);
    }

    /**
     * 验证姓名是否为中文
     * @param username
     * @return
     */
    public static boolean checkUsername(String username){
        return username.matches(USERNAME);
    }
}
//验证码的正则表达式